/// Creator：      gaoruishan 
/// CreatDate：    2025-05-22
/// Description:   API入口--3.0兼容4.0
Class Nur.MNISV3.Service.APIEntry Extends %RegisteredObject [ Not ProcedureBlock ]
{

/// -------------------兼容MNIS 3.0接口--------------------------------------
/// 登录
Parameter Logon = "Nur.MNISV3.Service.Logon:Logon";

/// 日志
Parameter Log = "Nur.MNISV3.Service.Logon:Log";

/// 登录前获取一些配置,比如广播，当前访问的服务器地址
Parameter GetLoginConfig = "Nur.MNISV3.Service.Config:GetLogonConfig";

/// 获取主界面模块及一些demo里的配置
Parameter GetMainConfig = "Nur.MNISV3.Service.Config:GetMainConfig";

/// 获取当前是否有新版本
Parameter GetNewVersion = "Nur.MNISV3.Service.Logon:GetNewVersion";

/// 新消息接口
Parameter GetNotifyListNew = "Nur.MNISV3.Service.Notification:GetNotifyListNew";

/// 获取病区患者列表
Parameter GetInWardPatList = "Nur.MNISV3.Service.Patient:GetWardPatList";

/// 护理病历
/// 获取demo维护的护理病历列表
Parameter GetModelList = "Nur.MNISV3.Service.NurEmr:GetModelList";

/// 解析护理病历模板
Parameter GetXmlValues = "Nur.MNISV3.Service.NurEmrConfig:GetXmlValues";

/// 获取多次评估单或护理记录单已评估列表
Parameter GetNewEmrList = "Nur.MNISV3.Service.NurEmr:GetNewEmrList";

/// 保存护理病历
Parameter SaveNewEmrData = "Nur.MNISV3.Service.NurEmr:SaveNewEmrData";

/// 获取模板xml数据
Parameter GetXmlValuesString = "Nur.MNISV3.Service.NurEmrConfig:GetXmlValuesString";

Parameter GetCodeList = "Nur.MNISV3.Service.NurEmrConfig:GetCodeList";

/// 护理病历列表界面，已评，科室，和全院模板的修改
Parameter AddModelList = "Nur.MNISV3.Service.NurEmr:AddModelList";

Parameter GetSoundData = "Nur.MNIS.Service.Sound:GetSoundData";

Parameter SetSoundData = "Nur.MNIS.Service.Sound:SetSoundData";

/// -------------------新增接口 带V4--------------------------------------- 
Parameter EditTextConvertV4 = "Nur.MNISV3.Service.Logon:EditTextConvertV4";

Parameter ValidateUserV4 = "Nur.MNISV3.Service.Logon:ValidateUserV4";

/// ****扫码****** 
Parameter GetScanInfoV4 = "Nur.MNISV3.Service.ScanEvents:GetScanInfoV4";

Parameter ExecOrSeeOrderV4 = "Nur.MNISV3.Service.ScanEvents:ExecOrSeeOrderV4";

/// 医嘱闭环配置 
Parameter GetOrderConfigV4 = "Nur.MNISV3.Service.Order:GetOrderConfigV4";

Parameter GetOrdersV4 = "Nur.MNISV3.Service.Order:GetOrdersV4";

Parameter GetOrderTasksV4 = "Nur.MNISV3.Service.Order:GetOrderTasksV4";

Parameter GetOrderDetailV4 = "Nur.MNISV3.Service.Order:GetOrderDetailV4";

Parameter OnSelectPatientV4 = "Nur.MNISV3.Service.Order:OnSelectPatientV4";

Parameter OnCheckOrderV4 = "Nur.MNISV3.Service.Order:OnCheckOrderV4";

/// 所管床
Parameter GetBedListSelectV4 = "Nur.MNISV3.Service.Bed:GetBedListSelectV4";

Parameter SetManagedBedsV4 = "Nur.MNISV3.Service.Bed:SetManagedBedsV4";

/// 在床患者列表
Parameter GetPatListSelectV4 = "Nur.MNISV3.Service.Bed:GetPatListSelectV4";

/// 手写板签名
Parameter SetSignaturePadV4 = "Nur.MNISV3.Service.NurEmrConfig:SetSignaturePadV4";

/// 床位图
Parameter GetBedMapPatientsV4 = "Nur.MNISV3.Service.Patient:GetBedMapPatientsV4";

Parameter GetBedMapAdditionsV4 = "Nur.MNISV3.Service.Patient:GetBedMapAdditionsV4";

Parameter GetBedMapPatientV4 = "Nur.MNISV3.Service.Patient:GetBedMapPatientV4";

/// 入院分床
Parameter GetAllotInfoV4 = "Nur.MNISV3.Service.Bed:GetAllotInfoV4";

Parameter AllotBedV4 = "Nur.MNISV3.Service.Bed:AllotBedV4";

Parameter GetPatInfoV4 = "Nur.MNISV3.Service.Patient:GetBedMapPatientV4";

/// Rfid绑定
Parameter GetRfidDataV4 = "Nur.MNISV3.Service.RfidBindRegNo:GetRfidDataV4";

Parameter BindRfidV4 = "Nur.MNISV3.Service.RfidBindRegNo:BindRfidV4";

Parameter UnbindRfidV4 = "Nur.MNISV3.Service.RfidBindRegNo:UnbindRfidV4";

/// 输液绑定
Parameter GetInfusionBindingDataV4 = "Nur.MNISV3.Service.RfidBindRegNo:GetInfusionBindingDataV4";

Parameter BindInfusionV4 = "Nur.MNISV3.Service.RfidBindRegNo:BindInfusionV4";

Parameter UnbindInfusionV4 = "Nur.MNISV3.Service.RfidBindRegNo:UnbindInfusionV4";

/// 医嘱单
Parameter GetOrderSheetV4 = "Nur.MNISV3.Service.OrderSheet:GetOrderSheetV4";

/// 手术查询
Parameter GetOpsDataV4 = "Nur.MNISV3.Service.Operation:GetOpsDataV4";

Parameter GetOpsFlowV4 = "Nur.MNISV3.Service.Operation:GetOpsFlowV4";

/// 检验查询
Parameter GetLabOrderDataV4 = "Nur.MNISV3.Service.Lab:GetLabOrderDataV4";

/// 检查查询
Parameter GetExamOrderDataV4 = "Nur.MNISV3.Service.Ris:GetExamOrderDataV4";

Parameter GetExamReportV4 = "Nur.MNISV3.Service.Ris:GetExamReportV4";

/// 事件管理 
Parameter GetPatEventsV4 = "Nur.MNISV3.Service.Temperature:GetPatEventsV4";

Parameter SaveEventV4 = "Nur.MNISV3.Service.Temperature:SaveEventV4";

Parameter DelEventV4 = "Nur.MNISV3.Service.Temperature:DelEventV4";

/// 生命体征  
Parameter GetTempPatListV4 = "Nur.MNISV3.Service.Temperature:GetTempPatListV4";

Parameter GetTempValueV4 = "Nur.MNISV3.Service.Temperature:GetTempValueV4";

Parameter SaveTempDataV4 = "Nur.MNISV3.Service.Temperature:SaveTempDataV4";

Parameter GetPatTempDetailV4 = "Nur.MNISV3.Service.Temperature:GetPatTempDetailV4";

Parameter GetTempTaskV4 = "Nur.MNISV3.Service.Temperature:GetTempTaskV4";

/// 陪护管理  
Parameter GetEscortDataV4 = "Nur.MNISV3.Service.Accompany:GetEscortDataV4";

Parameter GetEscortVitalSignDataV4 = "Nur.MNISV3.Service.Accompany:GetEscortVitalSignDataV4";

Parameter GetEscortTemplateV4 = "Nur.MNISV3.Service.Accompany:GetEscortTemplateV4";

Parameter EditEscortV4 = "Nur.MNISV3.Service.Accompany:EditEscortV4";

/// 外出管理  
Parameter GetOutDataV4 = "Nur.MNISV3.Service.OutManage:GetOutDataV4";

Parameter SaveOutV4 = "Nur.MNISV3.Service.OutManage:SaveOutV4";

Parameter ChangeOutStatusV4 = "Nur.MNISV3.Service.OutManage:ChangeOutStatusV4";

/// 交班查询  
Parameter GetNursingBookDataV4 = "Nur.MNISV3.Service.Shift:GetNursingBookDataV4";

/// 血糖   
Parameter GetSugarPatListV4 = "Nur.MNISV3.Service.Sugar:GetSugarPatListV4";

Parameter SaveSugarDataV4 = "Nur.MNISV3.Service.Sugar:SaveSugarDataV4";

Parameter GetPatSugarDetailV4 = "Nur.MNISV3.Service.Sugar:GetPatSugarDetailV4";

Parameter DeleteSugarDataV4 = "Nur.MNISV3.Service.Sugar:DeleteSugarDataV4";

/// 护嘱任务   
Parameter GetNursingTaskDataV4 = "Nur.MNISV3.Service.NurseTask:GetNursingTaskDataV4";

Parameter GetNursingTaskDetailV4 = "Nur.MNISV3.Service.NurseTask:GetNursingTaskDetailV4";

Parameter ExecuteNursingTaskV4 = "Nur.MNISV3.Service.NurseTask:ExecuteNursingTaskV4";

Parameter GetPrnInterventionsV4 = "Nur.MNISV3.Service.NurseTask:GetPrnInterventionsV4";

/// 任务总览 
Parameter GetTaskDataV4 = "Nur.MNISV3.Service.ExecuteSummary:GetTaskDataV4";

/// 健康宣教     
Parameter GetEducationDataV4 = "Nur.MNISV3.Service.Education:GetEducationDataV4";

Parameter GetEducationSubjectItemsV4 = "Nur.MNISV3.Service.Education:GetEducationSubjectItemsV4";

Parameter GetEducationContentItemsV4 = "Nur.MNISV3.Service.Education:GetEducationContentItemsV4";

Parameter ExecuteEducationV4 = "Nur.MNISV3.Service.Education:ExecuteEducationV4";

Parameter GetEducationMedicationV4 = "Nur.MNISV3.Service.Education:GetEducationMedicationV4";

/// 护理计划        
Parameter GetQuestionDataV4 = "Nur.MNISV3.Service.NursingPlan:GetQuestionDataV4";

Parameter EditQuestionV4 = "Nur.MNISV3.Service.NursingPlan:EditQuestionV4";

Parameter SaveQuestionV4 = "Nur.MNISV3.Service.NursingPlan:EditQuestionV4";

Parameter GetPlanDetailV4 = "Nur.MNISV3.Service.NursingPlan:GetPlanDetailV4";

Parameter EditPlanDetailV4 = "Nur.MNISV3.Service.NursingPlan:EditPlanDetailV4";

Parameter GetQuestionItemsV4 = "Nur.MNISV3.Service.NursingPlan:GetQuestionItemsV4";

/// 病区输液总览
Parameter GetInfusionDataV4 = "Nur.MNISV3.Service.InfusionOrd:GetInfusionDataV4";

/// 输血闭环  
Parameter GetBloodInfoV4 = "Nur.MNISV3.Service.Blood:GetBloodInfoV4";

Parameter ExecuteBloodV4 = "Nur.MNISV3.Service.Blood:ExecuteBloodV4";

Parameter GetBloodDataPreferencesV4 = "Nur.MNISV3.Service.Blood:GetBloodDataPreferencesV4";

Parameter GetBloodDataV4 = "Nur.MNISV3.Service.Blood:GetBloodDataV4";

Parameter GetBloodDataByPatV4 = "Nur.MNISV3.Service.Blood:GetBloodDataByPatV4";

Parameter GetBloodDetailV4 = "Nur.MNISV3.Service.Blood:GetBloodDetailV4";

/// 护理巡视  
Parameter GetTourDataV4 = "Nur.MNISV3.Service.TourRec:GetTourDataV4";

/// 患者交接 
Parameter GetConnectListV4 = "Nur.MNISV3.Service.PatHandover:GetConnectListV4";

Parameter GetScanConnectV4 = "Nur.MNISV3.Service.PatHandover:GetScanConnectV4";

Parameter SaveConnectV4 = "Nur.MNISV3.Service.PatHandover:SaveConnectV4";

Parameter GetConnectAndPatV4 = "Nur.MNISV3.Service.PatHandover:GetConnectAndPatV4";

Parameter SaveConnectSubV4 = "Nur.MNISV3.Service.PatHandover:SaveConnectSubV4";

/// Creator：      fengliang 
/// CreatDate：    2021-03-22
/// Description:   获取后台数据
/// Others：        w ##class(Nur.MNISV3.Common.JSON).Encode(##class(Nur.MNISV3.Service.APIEntry).RequestData("Logon","{""userCode"":""hs01"",""password"":""1""}",""))
ClassMethod RequestData(method, params, version, debugFlag = "0")
{
    n (method, params, version, %request, %session,debugFlag)
    s $zt="errRequstData"
    s msg="成功",msgcode="999999",status="0"
  
    //将前台获取的入参转成对象
    i '$IsObject(params) s paramObj = ##class(Nur.MNISV3.Common.JSON).Decode(params)
    e  s paramObj = params
    i (paramObj.IsDefined("auditUserCode ")) d // EH
    .d paramObj.SetAt(paramObj.GetAt("auditUserCode "),"auditUserCode")
    .d paramObj.SetAt(paramObj.GetAt("auditUserPass "),"auditUserPass")
    //首字母大写
    s method=$zcvt($e(method,1),"u")_$e(method,2,$l(method))
    
    s logonInfo=paramObj.GetAt("logonInfo")
    i logonInfo'="" 
    {
        s initSession=##class(Nur.MNISV3.Service.Session).InitSessionData(logonInfo) // EH 初始化session
        //s ^MML("RequstData",method,%session.Data("LOGON.USERID"))=$lb(method, params, version)
    }
    x "s methodStr=..#"_method
    i methodStr="" {
        s ^GRS("RequestDataV3",method)=$lb(method, params, version)
        q ##class(Nur.MNISV3.Common.Utils).ReturnMsgStream(method_"没有找到对应的方法!","100002","-1")
    }
    s className=$p(methodStr,":",1),methodName=$p(methodStr,":",2)
    s data=..MethodExcute(className,methodName,paramObj)    
    i debugFlag=1{
        i '$IsObject(data) q data
        q ##class(Nur.MNISV3.Common.JSON).Encode(data)
    }
    q ##class(Nur.MNISV3.Common.Utils).DataToStream(data)
errRequstData
    s msg=$ze
    q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJson(method_":"_msg,"false","-1")
}

/// Creator：      fengliang 
/// CreatDate：    2021-03-22
/// Description:   执行方法
ClassMethod MethodExcute(className As %String, methodName As %String, paramObj As %String) As %String
{
    n (className,methodName,paramObj,%request,%session)
    ;s ^MML("MethodExcute")=paramObj.GetAt("DataArr")
    ;s $zt="errMethodExcute"
    s x="s ret=##class("_className_")."_methodName_"("
    s paramStr = ..GetClassMethodParam(className,methodName)  //获取方法的入参串
    i paramStr'="" ;处理无参数
    {
        f i=1:1:$l(paramStr,"^")
        {
            i ($p(paramStr,"^",i)="session") {
                s x=x_$p(paramStr,"^",i)
            } else {
                s parameterVal = paramObj.GetAt(""_$p(paramStr,"^",i)_"")
                s parameterVal=##class(Nur.MNISV3.Common.JSON).Replace(parameterVal,"""","""""")
                ;s parameterVal=$replace(parameterVal," ","") ;替换所有空格
                s x=x_""""_parameterVal_""""
            }
            i i'=$l(paramStr,"^") s x=x_","
        }   
    }
    
    s x=x_")"
    x x
    q ret
errMethodExcute
    s msg=$ze
    q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJson("["_methodName_"]"_msg,"false","-1")
}

/// Creator：      fengliang 
/// CreatDate：    2021-03-22
/// Description:   获取类方法入参串
ClassMethod GetClassMethodParam(className As %String, classMethod) As %String
{
    n (className,classMethod)
    s methodParameter=$g(^oddCOM(className,"m",classMethod,60))
    q:methodParameter="" ""
    s parameterNum=$ll(methodParameter) , param=""
    f n=1:1:parameterNum d
    .s parameter=$li(methodParameter,n)
    .s parameterName=$li(parameter,1)
    .s param= $s(param="":parameterName,1:param_"^"_parameterName)
    q param
}

/// Creator：      fengliang 
/// CreatDate：    2021-03-22
/// Description:   获取类方法入参数量
/// w ##class(Nur.MNISV3.Service.APIEntry).GetParamCount("Nur.MNISV3.Service.Logon","Logon")
ClassMethod GetParamCount(className As %String, classMethod As %String)
{
    n (className,classMethod)
    s methodParameter=$g(^oddCOM(className,"m",classMethod,60))
    s parameterNum=$ll(methodParameter)
    q parameterNum
}

}
